package ru.maxmatveev.dyndao.demo.dao;

import ru.maxmatveev.dyndao.*;
import ru.maxmatveev.dyndao.demo.model.Child;
import ru.maxmatveev.dyndao.demo.model.Parent;

import java.util.List;

/**
 * @author Max Matveev
 *         Date: Jan 4, 2009
 *         Time: 5:03:52 PM
 */
public interface ComplexDao extends DynamicDao<Child, Long> {
    List<Child> getByParentId(
            @Restriction.ParentId(fieldName = "children", parentClass = Parent.class) Long parentId
    );

    List<Child> getByParentField(
            @Restriction.ParentField(fieldName = "children", parentClass = Parent.class, filterFieldName = "name", filterFieldComparison = Restriction.Comparison.ILIKE) String value
    );

    List<Child> getByParentRestriction(
            @Restriction.Parent(fieldName = "children", parentClass = Parent.class) Restriction restriction
    );

    @Count
    Integer getCountByParentId(
            @Restriction.ParentId(fieldName = "children", parentClass = Parent.class) Long parentId
    );

    @Count
    Integer getCountByParentField(
            @Restriction.ParentField(fieldName = "children", parentClass = Parent.class, filterFieldName = "name", filterFieldComparison = Restriction.Comparison.ILIKE) String value
    );

    @Count
    Integer getCountByParentRestriction(
            @Restriction.Parent(fieldName = "children", parentClass = Parent.class) Restriction restriction
    );

    List<Child> getPaginatedAndOrderedByCriteriaAndFilteredByParentRestrictionAndFilteredByRestriction(
            @Restriction.Parent(fieldName = "children", parentClass = Parent.class) Restriction parentRestriction,
            @Ordering.Criteria Ordering ordering,
            @Restriction.Restrict Restriction restriction,
            @Pagination.Paginate Pagination pagination
    );


}
